import store from '@/store';
import {
    getJobRecordService,
    cancleDeliveryService
} from '../service';
import { format } from 'fecha';

/**
 * 获取求职记录
 */
export async function getJobRecord(payload = {}) {
    const allData = await getJobRecordService(payload);
    if (allData.code >= 2000 && allData.code < 4000) {
        allData.data = allData.data.map((item)=>{
            if(item.deliveryTime) {
                item.deliveryTime = format(+item.deliveryTime, 'YYYY-MM-DD');
            }
            return item;
        });
        store.commit('setJobRecordList', allData.data); // 将获取到的数据值存到store中
    }
    return allData;
}

/**
 * 取消报名
 */
export async function cancleDelivery(payload = {}) {
    const allData = await cancleDeliveryService(payload);
    return allData;
}
